package org.example.ssh

import net.schmizz.sshj.SSHClient
import org.example.ssh.base.executeCmd
import java.io.File

class BatchRunContainer {
    fun main(ssh: SSHClient) {
        val deployDir = "/home/mydesk-deploy"
        val localDocDir = "./docker/v1"
        val localDoc = File(localDocDir)
        val remoteDeployDir = "$deployDir/${localDoc.name}"

        var res = executeCmd(ssh, "cd $remoteDeployDir && docker-compose -f run-compose.yml down")
        println(res)
        res = executeCmd(ssh, "cd $remoteDeployDir && docker-compose -f run-compose.yml up -d")
        println(res)
        res = executeCmd(ssh, "docker ps")
        println(res)
        println("重新启动容器完成")
    }
}